package 力扣._6450_k数组的最小总和;

import java.util.LinkedList;
import java.util.List;

public class Solution {
    public int minimumSum(int n, int k) {
        List<Integer> list = new LinkedList<>();
        int num = 1, i;
        while (list.size() < n) {
            for (i = 0; i < list.size(); i++) {
                if (list.get(i) + num == k)
                    break;
            }
            if (i == list.size())
                list.add(num);

            if (list.size() == n)
                break;
            num++;
        }
        int sum = 0;
        for (Integer t : list) {
            sum += t;
        }
        return sum;
    }

    public static void main(String[] args) {
        int i = new Solution().minimumSum(5, 4);
    }
}
